#include <iostream>
#include <signal.h>
#include <unistd.h>

using namespace std;

void Print()
{
    sigset_t pending;
    sigpending(&pending);

    for (int i = 31; i > 0; i--)
    {
        if (sigismember(&pending, i))
            cout << "1";
        else
            cout << "0";
    }
    cout << endl;
}

void handler(int signo)
{
    cout << "signo" << endl;

    int cnt = 10;
    while(cnt)
    {
        sleep(1);
        cnt--;
        Print();
    }

}

int main()
{

    struct sigaction sig;
    sigset_t block;
    sigemptyset(&block);

    sig.sa_flags = 0;
    sig.sa_mask = block;
    sig.sa_handler = handler;

    int val = sigaction(2, &sig, nullptr);
    if(val < 0) cout << "error" << endl;

    while(true)
    {
        Print();
        sleep(1);
    }

    return 0;
}